//
//  ViewController.m
//  CTWebViewDemo
//
//  Created by ST on 16/9/12.
//  Copyright © 2016年 CT. All rights reserved.
//

#import "ViewController.h"
#import "CTWebViewController.h"
#import "KINWebBrowserViewController.h"

@interface ViewController ()<KINWebBrowserDelegate>
/** 1. */
@property(nonatomic, strong)UIButton *buttonGoWeb ;
@end

@implementation ViewController

#pragma mark - --- 1.init 生命周期 ---

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.buttonGoWeb = [UIButton buttonWithType:UIButtonTypeCustom];
//    self.buttonGoWeb.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    self.buttonGoWeb.frame = CGRectMake(10, 64, 100, 40);
    self.buttonGoWeb.backgroundColor = [UIColor magentaColor];
    [self.buttonGoWeb addTarget:self action:@selector(gotoWebViewController) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.buttonGoWeb];
    
}

#pragma mark - --- 2.delegate 视图委托 ---
- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didStartLoadingURL:(NSURL *)URL {
    NSLog(@"Started Loading URL : %@", URL);
}

- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFinishLoadingURL:(NSURL *)URL {
    NSLog(@"Finished Loading URL : %@", URL);
}

- (void)webBrowser:(KINWebBrowserViewController *)webBrowser didFailToLoadURL:(NSURL *)URL withError:(NSError *)error {
    NSLog(@"Failed To Load URL : %@ With Error: %@", URL, error);
}

- (void)webBrowserViewControllerWillDismiss:(KINWebBrowserViewController*)viewController {
    NSLog(@"View Controller will dismiss: %@", viewController);
    
}

#pragma mark - --- 3.event response 事件相应 ---
- (void)gotoWebViewController
{
    KINWebBrowserViewController *webBrowser = [KINWebBrowserViewController webBrowser];
    [webBrowser setDelegate:self];
    [self.navigationController pushViewController:webBrowser animated:YES];
    [webBrowser loadURLString:@"https://www.baidu.com"];
//    [self.navigationController pushViewController:[CTWebViewController new] animated:YES];
}
#pragma mark - --- 4.private methods 私有方法 ---

#pragma mark - --- 5.setters 属性 ---

#pragma mark - --- 6.getters 属性 —--

@end
